﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Administracija.master" AutoEventWireup="true" CodeFile="AdministracijaDrveca.aspx.cs" Inherits="AdministracijaDrveca" ValidateRequest="false" %>

<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <script src="Skripte/Administracija/AdministracijaDrvo.js" type="text/javascript"></script>
     <script src="ckeditor/ckeditor.js" type="text/javascript"></script>
    <link href="Stilovi/AdministracijaDrvo.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div id="administracijaMeni">
    <ul class="meni_lista">
    <li><a href="Administracija.aspx">Administracija naslovna</a></li>
    <li><a href="AdministracijaClanaka.aspx">Administracija članaka</a></li>
    <li><a href="AdministracijaSlika.aspx">Administracija slika</a></li>
    <li><a href="AdministracijaRasadnika.aspx">Administracija rasadnika</a></li>
</ul>
</div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
<!--***********************Administracija drveca****************************************-->

<!--**********************Administracija rodova*****************************************-->
<div id="glavni">
   
    <h2>Dodavanje i editiranje rodova drveća</h2>
    <div id="dodavanjeRodaDrveta">
        
        <h3>Popis rodova drveća</h3>
        <asp:SqlDataSource ID="sdsRodovi" runat="server" 
            ConnectionString="<%$ ConnectionStrings:EnciklopedijaDrvecaConnectionString %>" 
            DeleteCommand="DELETE FROM [Rod] WHERE [RodID] = @RodID" 
            InsertCommand="INSERT INTO [Rod] ([LatinskiNaziv], [HrvatskiNaziv], [GalerijaID]) VALUES (@LatinskiNaziv, @HrvatskiNaziv, @GalerijaID)" 
            SelectCommand="SELECT rod.*,galerija.nazivgalerije from rod inner join galerija on rod.galerijaid=galerija.galerijaid" 
            UpdateCommand="UPDATE [Rod] SET [LatinskiNaziv] = @LatinskiNaziv, [HrvatskiNaziv] = @HrvatskiNaziv, [GalerijaID] = @GalerijaID WHERE [RodID] = @RodID">
            <DeleteParameters>
                <asp:Parameter Name="RodID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="LatinskiNaziv" Type="String" />
                <asp:Parameter Name="HrvatskiNaziv" Type="String" />
                <asp:Parameter Name="GalerijaID" Type="Int32" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="LatinskiNaziv" Type="String" />
                <asp:Parameter Name="HrvatskiNaziv" Type="String" />
                <asp:Parameter Name="GalerijaID" Type="Int32" />
                <asp:Parameter Name="RodID" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:GridView ID="grdRodovi" runat="server" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="RodID" 
            DataSourceID="sdsRodovi" BackColor="#000066" CellPadding="10" 
            ForeColor="White">
            <AlternatingRowStyle BackColor="#000099" />
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                    ShowSelectButton="True" CausesValidation="False" CancelText="Odustani" 
                    DeleteText="Briši" EditText="Uredi" InsertText="Dodaj" NewText="Novo" 
                    SelectText="Odaberi" UpdateText="Osvježi" >
                <ItemStyle Font-Bold="True" />
                </asp:CommandField>
                <asp:BoundField DataField="RodID" HeaderText="Id roda drveta" InsertVisible="False" 
                    ReadOnly="True" SortExpression="RodID" />
                <asp:BoundField DataField="LatinskiNaziv" HeaderText="Latinski naziv" 
                    SortExpression="LatinskiNaziv" />
                <asp:BoundField DataField="HrvatskiNaziv" HeaderText="Hrvatski naziv" 
                    SortExpression="HrvatskiNaziv" />
                <asp:BoundField DataField="GalerijaID" HeaderText="Id galerije" 
                    SortExpression="GalerijaID" Visible="False" />
                <asp:BoundField DataField="nazivgalerije" HeaderText="Naziv galerije" 
                    SortExpression="nazivgalerije" Visible="False" />
                <asp:TemplateField HeaderText="Naziv galerije">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList1" runat="server" 
                            DataSourceID="sdsPodaciGalerija" DataTextField="NazivGalerije" 
                            DataValueField="GalerijaID" SelectedValue='<%# Bind("GalerijaID") %>'>
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="sdsPodaciGalerija" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:EnciklopedijaDrvecaConnectionString %>" 
                            SelectCommand="SELECT * FROM [Galerija]"></asp:SqlDataSource>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label3" runat="server" Text='<%# Eval("NazivGalerije") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <HeaderStyle BackColor="Black" />
            <SelectedRowStyle BackColor="#006600" />
        </asp:GridView>
        <br />
        <div id="dodavanjeRodova">
            <div id="porukaDodavanjeRoda" runat="server"></div>
            <asp:SqlDataSource ID="sdsDodavanjeRodovaGalerija" runat="server" 
                ConnectionString="<%$ ConnectionStrings:EnciklopedijaDrvecaConnectionString %>" 
                SelectCommand="SELECT * FROM [Galerija]"></asp:SqlDataSource>
            <h3>Dodavanje novog roda drveća</h3>
            <p>
            <asp:Label id="lblNazivRodaHrvatski" runat="server" Text="Hrvatski naziv roda: "></asp:Label>
            <asp:TextBox id="txtNazivRodaHrvatski" runat="server" ValidationGroup="grupaDodajRod"></asp:TextBox >
            <br />
                <asp:RequiredFieldValidator ForeColor="Red" ControlToValidate="txtNazivRodaHrvatski" ID="RequiredFieldValidator1" runat="server" ErrorMessage="Morate upisati hrvatski naziv roda drveća" ValidationGroup="grupaDodajRod"></asp:RequiredFieldValidator>
            </p>
            <p>
            <asp:Label id="lblNazivRodaLatinski" runat="server" Text="Latinski naziv roda:"></asp:Label>
            <asp:TextBox id="txtNazivRodaLatinski" runat="server" ValidationGroup="grupaDodajRod"></asp:TextBox>
            <br />
             <asp:RequiredFieldValidator ForeColor="Red" ControlToValidate="txtNazivRodaLatinski" ID="RequiredFieldValidator2" runat="server" ErrorMessage="Morate upisati latinski naziv roda drveća" ValidationGroup="grupaDodajRod"></asp:RequiredFieldValidator>
            </p>
            <p>
            <asp:Label id="lblNazivGalerije" runat="server" Text="Naziv galerije:"></asp:Label>
            <asp:DropDownList id="ddlNazivGalerije" runat="server" 
                DataSourceID="sdsDodavanjeRodovaGalerija" DataTextField="NazivGalerije" 
                DataValueField="GalerijaID"> </asp:DropDownList>
            <br />
            </p>
            <asp:Button ID="btnDodajRod" runat="server" Text="Dodaj rod" 
                onclick="btnDodajRod_Click" ValidationGroup="grupaDodajRod" />
        </div>

    </div>

<!--**************************Administracija rodova****************************************************-->

<!--**************************Administracija članaka o drveću******************************************-->

<!--**************************jDialog div**************************************************************-->
<div id="editiranjeClankaDialog" class="editiranjeClanakaDialog">
    
    <CKEditor:CKEditorControl id="ftbEditirajClanak" runat="server" ClientIDMode="Static"></CKEditor:CKEditorControl>
    <asp:Button id="btnEditiranjeOk" class="btnEditiranjeOk" runat="server" Text="Potvrdi" />
    <asp:Button id="btnEditiranjeOdustani" class="btnEditiranjeOdustani" runat="server" Text="Odustani" />
    
</div>
<!--*********************************jDialog div************************************************************-->
<h2>Podaci o člancima i editiranje</h2>
    <div id="dodavanjeClanakaODrvecu">
        
        <asp:SqlDataSource ID="sdsClanciODrvecu" runat="server" 
            ConnectionString="<%$ ConnectionStrings:EnciklopedijaDrvecaConnectionString %>" 
            DeleteCommand="DELETE FROM [Drvo] WHERE [DrvoID] = @DrvoID" 
            InsertCommand="INSERT INTO [Drvo] ([LatinskiNaziv], [HrvatskiNaziv], [Svjetlost], [VrstaTla], [MinimalnaTemperatura], [ProsjecniGodisnjiPrirast], [MaksimalnaVisina], [RodID], [GalerijaID]) VALUES (@LatinskiNaziv, @HrvatskiNaziv, @Svjetlost, @VrstaTla, @MinimalnaTemperatura, @ProsjecniGodisnjiPrirast, @MaksimalnaVisina, @RodID, @GalerijaID)" 
            SelectCommand="SELECT [DrvoID], [LatinskiNaziv], [HrvatskiNaziv], [Svjetlost], [VrstaTla], [MinimalnaTemperatura], [ProsjecniGodisnjiPrirast], [MaksimalnaVisina], [RodID], [GalerijaID] FROM [Drvo] where RodID=@RodId" 
            
            UpdateCommand="UPDATE [Drvo] SET [LatinskiNaziv] = @LatinskiNaziv, [HrvatskiNaziv] = @HrvatskiNaziv, [Svjetlost] = @Svjetlost, [VrstaTla] = @VrstaTla, [MinimalnaTemperatura] = @MinimalnaTemperatura, [ProsjecniGodisnjiPrirast] = @ProsjecniGodisnjiPrirast, [MaksimalnaVisina] = @MaksimalnaVisina, [RodID] = @RodID, [GalerijaID] = @GalerijaID WHERE [DrvoID] = @DrvoID">
            <DeleteParameters>
                <asp:Parameter Name="DrvoID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="LatinskiNaziv" Type="String" />
                <asp:Parameter Name="HrvatskiNaziv" Type="String" />
                <asp:Parameter Name="Svjetlost" Type="String" />
                <asp:Parameter Name="VrstaTla" Type="String" />
                <asp:Parameter Name="MinimalnaTemperatura" Type="Int32" />
                <asp:Parameter Name="ProsjecniGodisnjiPrirast" Type="Int32" />
                <asp:Parameter Name="MaksimalnaVisina" Type="Int32" />
                <asp:Parameter Name="RodID" Type="Int32" />
                <asp:Parameter Name="GalerijaID" Type="Int32" />
            </InsertParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="grdRodovi" Name="RodId" 
                    PropertyName="SelectedValue" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="LatinskiNaziv" Type="String" />
                <asp:Parameter Name="HrvatskiNaziv" Type="String" />
                <asp:Parameter Name="Svjetlost" Type="String" />
                <asp:Parameter Name="VrstaTla" Type="String" />
                <asp:Parameter Name="MinimalnaTemperatura" Type="Int32" />
                <asp:Parameter Name="ProsjecniGodisnjiPrirast" Type="Int32" />
                <asp:Parameter Name="MaksimalnaVisina" Type="Int32" />
                <asp:Parameter Name="RodID" Type="Int32" />
                <asp:Parameter Name="GalerijaID" Type="Int32" />
                <asp:Parameter Name="DrvoID" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:GridView ID="grdClanciOdrvecu" runat="server" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="DrvoID" 
            DataSourceID="sdsClanciODrvecu" BackColor="#000066" CellPadding="10" 
            ForeColor="White">
            <AlternatingRowStyle BackColor="#000099" />
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                    CancelText="Odustani" DeleteText="Izbriši" EditText="Uredi" InsertText="Dodaj" 
                    NewText="Novo" SelectText="Odaberi" UpdateText="Potvrdi" />
                <asp:BoundField DataField="DrvoID" HeaderText="DrvoID" InsertVisible="False" 
                    ReadOnly="True" SortExpression="DrvoID" />
                <asp:BoundField DataField="LatinskiNaziv" HeaderText="LatinskiNaziv" 
                    SortExpression="LatinskiNaziv" />
                <asp:BoundField DataField="HrvatskiNaziv" HeaderText="HrvatskiNaziv" 
                    SortExpression="HrvatskiNaziv" />
                <asp:BoundField DataField="Svjetlost" HeaderText="Svjetlost" 
                    SortExpression="Svjetlost" />
                <asp:BoundField DataField="VrstaTla" HeaderText="VrstaTla" 
                    SortExpression="VrstaTla" />
                <asp:BoundField DataField="MinimalnaTemperatura" 
                    HeaderText="MinimalnaTemperatura" SortExpression="MinimalnaTemperatura" />
                <asp:BoundField DataField="ProsjecniGodisnjiPrirast" 
                    HeaderText="ProsjecniGodisnjiPrirast" 
                    SortExpression="ProsjecniGodisnjiPrirast" />
                <asp:BoundField DataField="MaksimalnaVisina" HeaderText="MaksimalnaVisina" 
                    SortExpression="MaksimalnaVisina" />
                <asp:BoundField DataField="RodID" HeaderText="RodID" SortExpression="RodID" 
                    Visible="True" />
                <asp:BoundField DataField="GalerijaID" HeaderText="GalerijaID" 
                    SortExpression="GalerijaID" Visible="True" />
                <asp:TemplateField HeaderText="Uređivanje članka">
                    <ItemTemplate>
                        <asp:Button id="btnEditClanak" class="btnEditClanak" runat="server" 
                            Text="Uredi članak" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <HeaderStyle BackColor="Black" />
            <SelectedRowStyle BackColor="#006600" />
        </asp:GridView>
        <!--******************Dodavanje novog drveta**************************************************-->
        <h2>Dodavanje novog drveta</h2>

        <div id="dodajDrvo">
        <div id="porukaOdodavanjuDrveta" runat="server"></div>
        <p>
            <asp:Label id="lblHrvatskiNazivDrveta" runat="server" Text="Hrvatski naziv drveta:"></asp:Label>
            <asp:TextBox id="txtHrvatskiNazivDrveta" runat="server" ValidationGroup="grupaDodajDrvo"></asp:TextBox>
            <br />
            <asp:RequiredFieldValidator ControlToValidate="txtHrvatskiNazivDrveta" ForeColor="Red" ID="RequiredFieldValidator3" runat="server" ErrorMessage="Morate upisati hrvatski naziv drveta" ValidationGroup="grupaDodajDrvo"></asp:RequiredFieldValidator>
        </p>

        <p>
            <asp:Label id="lblLatinskiNazivDrveta" runat="server" Text="Latinski naziv drveta:"></asp:Label>
            <asp:TextBox id="txtLatinskiNazivDrveta" runat="server" ValidationGroup="grupaDodajDrvo"></asp:TextBox>
            <br />
            <asp:RequiredFieldValidator ControlToValidate="txtLatinskiNazivDrveta" ForeColor="Red" ID="RequiredFieldValidator4" runat="server" ErrorMessage="Morate upisati latinski naziv drveta" ValidationGroup="grupaDodajDrvo"></asp:RequiredFieldValidator>
        </p>

        <h2>Unesite text članka o drvetu</h2>
        <p>
        
  
        <CKEditor:CKEditorControl runat="server" id="ftbClanakODrvetu"></CKEditor:CKEditorControl>
        </p>

        <p>
         <asp:Label id="lblSvjetlost" runat="server" Text="Tolerancija na svjetlost:"></asp:Label>
         <br />
            <asp:TextBox id="txtSvjetlost" runat="server" ></asp:TextBox>
            <br />
        </p>

         <p>
         <asp:Label id="lblVrstaTla" runat="server" Text="Poželjna vrsta tla za sadnju:"></asp:Label>
         <br />
            <asp:TextBox id="txtVrstaTla" runat="server" ></asp:TextBox>
            <br />
        </p>

         <p>
         <asp:Label id="lblMinimalnaTemperatura" runat="server" Text="Minimalna temperatura koju drvo može podnijeti:"></asp:Label>
         <br />
            <asp:TextBox id="txtMinimalnaTemperatura" runat="server" ></asp:TextBox>
            <br />
        </p>

         <p>
         <asp:Label id="lblProsjecniGodisnjiPrirast" runat="server" Text="Prosječni godišnji prirast u centimetrima:"></asp:Label>
         <br />
            <asp:TextBox id="txtProsjecniGodisnjiPrirast" runat="server" ></asp:TextBox>
            <br />
        </p>

         <p>
         <asp:Label id="lblMaksimalnaVisina" runat="server" Text="Maksimalna visina u metrima:"></asp:Label>
         <br />
            <asp:TextBox id="txtMaksimalnaVisina" runat="server" ></asp:TextBox>
            <br />
        </p>

        <p>
            <asp:Label id="lblNazivRoda" runat="server" Text="Rod drveta:"></asp:Label>
            <br />
            <asp:DropDownList id="ddlNazivRodaDrveta" runat="server" 
                DataSourceID="sdsDodavanjeDrvetaRodovi" DataTextField="LatinskiNaziv" 
                DataValueField="RodID"></asp:DropDownList>
            <asp:SqlDataSource ID="sdsDodavanjeDrvetaRodovi" runat="server" 
                ConnectionString="<%$ ConnectionStrings:EnciklopedijaDrvecaConnectionString %>" 
                SelectCommand="SELECT [RodID], [LatinskiNaziv] FROM [Rod]"></asp:SqlDataSource>
        </p>


        <p>
            <asp:Label id="lblDodavanjeDrvetaNazivGalerije" runat="server" Text="Galerija:"></asp:Label>
            <br />
            <asp:DropDownList id="ddlDodavanjeDrvetaGalerija" runat="server" 
                DataSourceID="sdsDodavanjeDrvetaGalerija" DataTextField="NazivGalerije" 
                DataValueField="GalerijaID"></asp:DropDownList>
            <asp:SqlDataSource ID="sdsDodavanjeDrvetaGalerija" runat="server" 
                ConnectionString="<%$ ConnectionStrings:EnciklopedijaDrvecaConnectionString %>" 
                SelectCommand="SELECT * FROM [Galerija]"></asp:SqlDataSource>
        </p>

        <p>
            <asp:Label id="lblDodavanjeDrvetaTip" runat="server" Text="Tip drveta"></asp:Label>
            <br />
            <asp:DropDownList id="ddlDodavanjeDrvetaTip" runat="server" 
                DataSourceID="sdsDodavanjeDrvetaTip" DataTextField="Naziv" 
                DataValueField="TipDrvetaID"></asp:DropDownList>
            <asp:SqlDataSource ID="sdsDodavanjeDrvetaTip" runat="server" 
                ConnectionString="<%$ ConnectionStrings:EnciklopedijaDrvecaConnectionString %>" 
                SelectCommand="SELECT * FROM [TipDrveta]"></asp:SqlDataSource>
        </p>


        <p>
            <span>
            <asp:Button id="btnDodajDrvo" runat="server" Text="Dodaj drvo" 
                ValidationGroup="grupaDodajDrvo" onclick="btnDodajDrvo_Click" />
            </span>
            
        </p>
        </div>

         <!--********************Dodavanje novog drveta******************************************************-->
    </div>

</div>


</asp:Content>

